clc;
syms x y;
z(x,y)=(x^2-2*x)*exp(-x^2-y^2-x*y);
zx=simplify(diff(z,x));
zy=diff(z,y);
pretty(zx)
pretty(zy)


[x0,y0]=meshgrid(-3:.2:2,-2:.2:2);
z0=double(z(x0,y0));
figure()
surf(x0,y0,z0),
zlim([-0.7 1.5])%限定z轴显示范围

figure()
contour(x0,y0,z0,30),hold;
zx0=double(zx(x0,y0));
zy0=double(zy(x0,y0));
quiver(x0,y0,-zx0,-zy0)